<?php

namespace Auth\Form;

use Zend\Form\Form;

class LoginForm extends Form
{
    public function __construct($name = null) {
        parent::__construct('login');
        $this->setAttribute('method', 'post');
        $this->setInputFilter(new LoginFilter());
        $this->add(array(
            'name' => 'id' ,
            'type' => 'hidden' ,
        ));
         
        $this->add(array(
            'name' => 'username' ,
            'type' => 'text' ,
            'options' => array(
                'label' => 'Username' ,
            ),
            'attributes' => array(                
                'class' => 'form-control' ,
                'data-ng-model' => 'user.username' ,
                'maxlength' => 32
            ),
        ));
        
        $this->add(array(
            'name' => 'password' ,
            'type' => 'password' ,
            'options' => array(
                'label' => 'password' ,
            ),
            'attributes' => array(
                'class' => 'form-control' ,
                'data-ng-model' => 'user.password' ,
                'maxlength' => 32
            ),
        ));
        
        $this->add(array(
            'name' => 'csrf' ,
            'type' => Csrf
        ));
        
        $this->add(array(
            'name' => 'submit' ,
            'type' => 'submit' ,
            'options' => array(
                'label' => 'Login' ,
            ),
            'attributes' => array(
                'value' => 'Login' , 
                'class' => 'btn btn-primary' ,                
            ),
        ));
    }
}